//
//  MPViewController.m
//  MPTToolsLibrary
//
//  Created by jxzjxz on 07/11/2017.
//  Copyright (c) 2017 jxzjxz. All rights reserved.
//

#import "MPViewController.h"
#import "MPBFilePath.h"
#import "MPBTools+FilePath.h"
#import "NSString+Tools.h"
#import "MPBTools+StatusbarManager.h"
#import "MPBTools+Emoji.h"
#import "MPBTools+Method.h"
#import "MPBSubTest.h"
#import "MPBModelHeader.h"


@interface MPViewController ()
{
    MPBSubTest *testSub;
    NSThread *thread;
}
@end

@implementation MPViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(100, 100, 100, 100);
    //    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    [btn addTarget:self action:@selector(btnGetUnNormalEmj) forControlEvents:UIControlEventTouchUpInside];
    
    btn.backgroundColor = [UIColor redColor];
    [self.view addSubview:btn];
    
    UITextField *text = [[UITextField alloc] initWithFrame:CGRectMake(100, 250, 200, 50)];
    text.borderStyle = UITextBorderStyleLine;
    [self.view addSubview:text];
    
    
    NSLog(@"dddd");
    
    
    
    
    
//    
//    
//    // 交换
//    [MPBTools swizzleOrigSelector:@selector(showName) newSelector:@selector(showNameSub) inClass:[MPBSubTest class]];
//    
//    
//   MPBSubTest *test = [[MPBSubTest alloc] init];
//    [test showNameSub];
    
    testSub = [[MPBSubTest alloc] init];
//    thread = [[NSThread alloc] initWithTarget:testSub selector:@selector(showNameSub) object:nil];
//    [thread setName:@"TextSub"];
//    [thread start];
//    thread = [[NSThread alloc] initWithTarget:[self class] selector:@selector(addRunloopForTimer) object:nil];
//    [thread start];
    
    
//    [testSub performSelector:@selector(showNameSub) onThread:thread withObject:nil waitUntilDone:NO];
    
    [MPBTools performSelector:@selector(showNameSub) onObj:testSub onThread:@"testSubA" withObject:nil waitUntilDone:NO];


//    [MPBTools addAsyncMethod:@selector(showNameSub) target:testSub timeInterval:5 repeat:YES inQueue:dispatch_queue_create("jjjdjjdjdjd", nil) Mode:nil];
    
    
    
    
    //
//    MPBFilePath *path = [[MPBFilePath alloc] init];
//    
//    NSString *paths = path.cachesPath.subPathName(@"NNNNN").subPathName(@"MMMMM").subFileName(@"text.txt");
//    
//    [@{@"kdjdj":@1} writeToFile:paths atomically:YES];
//    
//    NSLog(@"");
//    
//    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
//    btn.frame = CGRectMake(100, 100, 100, 100);
//    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
//    btn.backgroundColor = [UIColor redColor];
//    [self.view addSubview:btn];
    
	// Do any additional setup after loading the view, typically from a nib.
}

+ (void)addRunloopForTimer
{
    @autoreleasepool
    {
        [[NSThread currentThread] setName:@"SubTest"];
        
        NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
        [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];
        [runLoop run];
    }
}

- (void)shouldRefreshMsgRecord
{
    NSLog(@"%d",[[NSThread currentThread] isMainThread]);
}

- (void)btnGetUnNormalEmj
{
    
    [MPBTools removeAsyncMethodInTarget:testSub];
    
////    [MPBTools getAllSystemEmoji];
//    NSMutableArray *maryg = [NSMutableArray arrayWithCapacity:0];
//    [MPBTools getAllSystemEmoji:maryg];
//    
//    NSLog(@"dddd");

}

- (BOOL)shouldAutorotate
{
    return NO;
}

- (void)btnClick
{
//    CGFloat duration = [UIApplication sharedApplication].statusBarOrientationAnimationDuration;
//    [UIView animateWithDuration:duration animations:^{
//        // 修改状态栏的方向及view的方向进而强制旋转屏幕
//        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
//        self.navigationController.view.transform = CGAffineTransformIdentity;
//        self.navigationController.view.bounds = CGRectMake(self.navigationController.view.bounds.origin.x, self.navigationController.view.bounds.origin.y, self.view.frame.size.height, self.view.frame.size.width);
//    }];
    
    [MPBTools setStatusbarDirection:UIInterfaceOrientationLandscapeRight animation:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
